﻿using System.Collections.Generic;
using System.ComponentModel;
using System.Windows.Controls;
using AutoCorrelatorGUI.Model;
using GalaSoft.MvvmLight;
using GalaSoft.MvvmLight.Messaging;

namespace AutoCorrelatorGUI.ViewModel
{
   /// <summary>
   /// This class contains properties that a View can data bind to.
   /// <para>
   /// See http://www.galasoft.ch/mvvm
   /// </para>
   /// </summary>
   public class StatsColumnSelectViewModel : ViewModelBase
   {
      /// <summary>
      /// Initializes a new instance of the StatsColumnSelectViewModel class.
      /// </summary>
      public StatsColumnSelectViewModel()
      {
      }

      /// <summary>
      /// The <see cref="StatsColumns" /> property's name.
      /// </summary>
      public const string StatsColumnsPropertyName = "StatsColumns";

      private BindingList<StatsColumnItem> _StatsColumns = null;

      /// <summary>
      /// Sets and gets the StatsColumns property.
      /// Changes to that property's value raise the PropertyChanged event. 
      /// </summary>
      public BindingList<StatsColumnItem> StatsColumns
      {
         get
         {
            return _StatsColumns;
         }

         set
         {
            if (_StatsColumns == value)
            {
               return;
            }

            _StatsColumns = value;
            RaisePropertyChanged(StatsColumnsPropertyName);
         }
      }

      public List<DataGridColumn> GetAllActiveColumns()
      {
         var active = new List<DataGridColumn>();

         foreach (var item in StatsColumns)
         {
            active.AddRange(item.GetAllChildColumns());
         }

         return active;
      }
   }
}